#include "EntityManager.h"

#ifndef NULL
#define NULL 0
#endif

EntityManager* EntityManager::Instance() {
	static EntityManager instance;
	return &instance;
}



void EntityManager::registerEntity(BaseEntity* p_newEntity) {
	m_entityMap.insert(std::make_pair(p_newEntity->getID(), p_newEntity));
}



BaseEntity* EntityManager::getEntityFromID(int p_ID) const {
	std::map<int, BaseEntity*>::const_iterator ent = m_entityMap.find(p_ID);
	if(ent !=  m_entityMap.end()) {
		return ent->second;
	}
	else {
		return NULL;
	}
}



void EntityManager::removeEntity(BaseEntity* p_entity) {
	m_entityMap.erase(m_entityMap.find(p_entity->getID()));
}
